var xmlapp = Components.classes["@milowski.com/xmlapp;1"].getService(Components.interfaces.nsISupports).wrappedJSObject;
var _mainWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator).getMostRecentWindow("navigator:browser");
var EXT_ID = "{6a545900-e51a-493a-8682-e246b64fe728}";

function XMLAppOverlay() {

}

XMLAppOverlay.prototype.onOpenConfiguration = function() {
   alert("Not implemented");
}

XMLAppOverlay.prototype.onOpenSample = function() {
   try {
      var extLocation = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager).getInstallLocation(EXT_ID);

      var sampleFile = extLocation.getItemFile(EXT_ID,"applications/helloworld/sample.hello");
      var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
      var sampleURI = ios.newFileURI(sampleFile);
      var tabBrowser = _mainWindow.getBrowser();
      var tab = tabBrowser.addTab(sampleURI.spec);
      tabBrowser.selectedTab = tab;
   } catch (ex) {
      alert(ex);
   }
}

XMLAppOverlay.getInstance = function() {
   if (!XMLAppOverlay.instance) {
      XMLAppOverlay.instance = new XMLAppOverlay();
   }
   return XMLAppOverlay.instance;
}

